var app = getApp();
Page({
    data:{
        curPage : "/zofui_sales/fenxiao/index",
        page : {
            isend : false,
            doing : false,
            doo : 'fenxiao',
            pdata : {
                op : 'indexlist',
                page : 2,
                status : 0,
            },
            waitf : 0,
            nodataf : 0,
        },
        datalist : [],
        Menu: [{
            url: "/zofui_sales/pages/index/index",
            iconPath: "https://img11.360buyimg.com/ddimg/jfs/t1/66538/19/4014/3269/5d2351f9E53638303/d16ba3ba1f225e55.png",
            selectedIconPath: "https://img11.360buyimg.com/ddimg/jfs/t1/66538/19/4014/3269/5d2351f9E53638303/d16ba3ba1f225e55.png",
            title: "首页",
            type: "tabbar"
        }, {
            url: "/zofui_sales/fenxiao/goods",
            iconPath: "https://img11.360buyimg.com/ddimg/jfs/t1/76564/29/4072/4005/5d235934E9e4fec12/485ebe5e6f2b173f.png",
            selectedIconPath: "https://img11.360buyimg.com/ddimg/jfs/t1/53034/40/4498/4044/5d235938E08362533/0b26e6d2c077df6b.png",
            title: "销售"
        }, {
            url: "/zofui_sales/fenxiao/bill",
            iconPath: "https://img11.360buyimg.com/ddimg/jfs/t1/49710/34/4519/3981/5d235a12E2cc284ad/a4a02c22c99b4b61.png",
            selectedIconPath: "https://img11.360buyimg.com/ddimg/jfs/t1/34162/25/14452/4622/5d235a15E1e64565f/3900800ba49583a9.png",
            title: "资金",
        }, {
            url: "/zofui_sales/fenxiao/user",
            iconPath: "https://img11.360buyimg.com/ddimg/jfs/t1/45769/18/4567/6267/5d235b21Efff10c3e/507efc3f920d8740.png",
            selectedIconPath: "https://img11.360buyimg.com/ddimg/jfs/t1/72323/28/3988/6330/5d235b25E127fda9d/ecbb0c9f41cf8633.png",
            title: "结算中心"
        }],
        isIPX : app.globalData.isIPX,
		siteroot : app.siteInfo.siteroot.replace('app/index.php', ''),uniacid: app.siteInfo.uniacid,
    },
    onLoad:function(options){
        var self = this;
        var uid = options.uid ? options.uid : '';
        self.setData({
            options : options,
        });
        app.com.auth(function(user){
            app.com.http('fenxiao','POST',{uid:uid,op:'index'},0,false,'','',function(res){
                if (!res.data.errno) {
                    self.setData({
                        params : res.data.data.params,
                        datalist : res.data.data.goods,
                        uinfo : res.data.data.user,
                        inited : true,
                    });
                    // 关闭下拉刷新
                    wx.stopPullDownRefresh();
                }else{
                    app.com.alert(res.data.message);
                }
            });
        });
        wx.setNavigationBarTitle({
          title:  '店铺',
        });
       
    },
    onShareAppMessage : function(){
        var self = this;
        return {
            title: self.data.article.title,
            path: '',
            imageUrl : self.data.article.img,
        }
    },
    tabChange(e){
        var self = this;

        if( self.data.ising || ( e.target.dataset.status < 3 && e.target.dataset.status == self.data.page.pdata.status ) ) return false;
        self.data.ising = true;

        self.setData({
            'page.pdata.status' : e.currentTarget.dataset.status,
            'page.pdata.page' : 1,
            'page.isend' : false,
            'page.waitf' : 0,
            'page.nodataf' : 0
        });

        app.com.getPage(self,self.data.page,20,function(res){
            self.setData({
                datalist : res.data.data.list,
            });
            wx.pageScrollTo({
                scrollTop: 0
            });
        });

        self.data.ising = false;
    },
    onReachBottom : function(){
        var self = this;
        app.com.getPage(self,self.data.page,20,function(res){
            self.setData({
                datalist : self.data.datalist.concat(res.data.data.list)
            });
        });
    },
    location : function( e ){
        app.com.location( e );
    },
    otherapp : function( e ){
        app.com.otherapp( e );
    },
    navigateto : function( e ){
        app.com.navigateto( e );
    },
    redirectto : function( e ){
        app.com.redirectto( e );
    },    
    callphone : function(e){
        app.com.callphone( e );
    },
    toweburl : function(e){
        app.com.toweburl( e );
    },
    showimages : function( e ){
        app.com.showimages( e );
    },
    footNavigate(e){
        var url = e.currentTarget.dataset.url;
        wx.switchTab({
          url: url
        })
    },

})